package leetcode.code1640;

public class Solution {
	public boolean canFormArray(int[] arr, int[][] pieces) {
		int[] map = new int[101];
		for (int i = 0; i < pieces.length; i++) {
			map[pieces[i][0]] = i;
		}
		int p = 0;
		while (p < arr.length) {
			int num = arr[p];
			int[] piece = pieces[map[num]];
			int i = 0;
			while (i < piece.length) {
				if (piece[i] != arr[p]) {
					return false;
				}
				i++;
				p++;
			}
		}
		return true;
	}
}
